module.exports = {
  onLogin(data = {}) {
    this.$store.commit('system/login', data);
    uni.$emit('login', data);
  },
  checkSession() {
    // #ifdef MP
    return new Promise((resolve, reject) => {
      uni.checkSession({
        success: resolve,
        fail: reject,
      })
    })
    // #endif
  },
  connectLogin(provider, options = {}) {
    provider = provider == 'wechat' ? 'weixin' : provider;
    return new Promise((resolve, reject) => {
      uni.login({
        ...options,
        provider: provider,
        success: (res) => {
          resolve(res);
        },
        fail: reject
      })
    })
  },
}
